package com.aya.tb.context;

import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import org.springframework.stereotype.Service;

import java.lang.reflect.Parameter;

@Service
public class ChannelArgumentSupportHandler implements ArgumentSupportHandler {
    @Override
    public boolean support(Parameter parameter, byte[] body, ChannelHandlerContext ctx) {
        return Channel.class.isAssignableFrom(parameter.getType());
    }

    @Override
    public Object handler(Parameter parameter, byte[] body, ChannelHandlerContext ctx) {
        return ctx.channel();
    }
}
